define(function(require, exports){
	var utilDSP = require('modules/common');
	// 报表中心
	exports.onMain = function(boot, data, app){
		var title = LANG('报表中心');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title:title,
			type: 'sidebar',
			content_config: {
				'addClass': 'cool',
			}
		});
		app.core.get('SYS_PLATFORM').setPlatform(title);
	}
	// 自定义报表
	exports.onCustom = function(boot,data,app){
		if(!app.routerValid('')) {
			return;
		}
		var title = LANG('自定义报表');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'sidebar'
		});
		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': 'report'
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		con.createBusiness(data.name, 'report/action/list.customReport', {
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});

	};

	// 新建报表
	exports.onCustomReportEdit = function(boot, data, app){
		// todo权限判断
		var id = +data.param;
		var title = id ? LANG('编辑报表') : LANG('新建报表');

		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'scroll'
		});

		con.createBusiness(data.name, 'report/action/edit.base', {
		}, function(mod){
			mod.reset();
			if (id) {
				mod.load(id);
			}
		});
	}

	// 资源报表
	exports.onResourceReport = function(boot, data, app){
		var title = LANG('资源报表');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'tabSidebar',
			content_config: {
				'addClass': 'cool',
			}
		});
		//设置标题
		app.core.get('SYS_PLATFORM').setPlatform(title);
		con.createBusiness(data.name + "channel", 'report/action/list.resourceReport',{
			tabText: LANG('渠道'),
			tabType: 'channel',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
		con.createBusiness(data.name + "adsense", 'report/action/list.resourceReport',{
			tabText: LANG('广告位'),
			tabType: 'adsense',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
		con.createBusiness(data.name + "order", 'report/action/list.resourceReport',{
			tabText: LANG('订单'),
			tabType: 'order',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
	}

	// 汇总数据
	exports.onSummaryReport = function(boot, data, app){
		var title = LANG('汇总数据');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title:"",
			type: 'tabSidebar',
			content_config: {
				'addClass': 'cool',
			}
		});
		//设置标题
		app.core.get('SYS_PLATFORM').setPlatform(title);
		con.createBusiness(data.name + "account", 'report/action/list.summaryReport', {
			tabText: LANG('账户'),
			tabType: 'account',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
		con.createBusiness(data.name + "adsense", 'report/action/list.summaryReport', {
			tabText: LANG('广告主'),
			tabType: 'adsense',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
		con.createBusiness(data.name + "channel", 'report/action/list.summaryReport', {
			tabText: LANG('渠道'),
			tabType: 'channel',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
	}


});